"""
主机类
"""
from db.excel_handler import excel_save


class Host:
    def __init__(self, host_id, ip, **kwargs):
        self.host_id = host_id  # 主机行
        self.ip = ip  # 主机ip
        self.account = kwargs.get("account")  # 主机从账号
        self.role = kwargs.get("role")  # 授权角色
        self.os_release = None
        self.connect_status = None
        self.sync_status = None
        self.account_status = None
        self.auth_status = None
        self.is_bad = None
        self.is_manual_sync = False

    def save(self):
        excel_save(self, self.host_id)

    def __str__(self):
        return "%s %s %s %s %s %s %s %s %s\n" % (
            self.host_id,
            self.ip, self.account, self.role, self.os_release, self.connect_status, self.sync_status,
            self.account_status,
            self.auth_status)

    def __repr__(self):
        return "%s %s %s %s %s %s %s %s %s\n" % (
            self.host_id,
            self.ip, self.account, self.role, self.os_release, self.connect_status, self.sync_status,
            self.account_status,
            self.auth_status)
